package imp

import (
	"bgs/cache/redisImp"
	"bgs/conf"
	"bgs/db"
	"bgs/grpc/client"
	activityGrpc "bgs/grpc/gen/service/activity"
	activityStatGrpc "bgs/grpc/gen/service/activity_stat"
	activityUserAwardGrpc "bgs/grpc/gen/service/activity_user_award"
	activityUserProcedureGrpc "bgs/grpc/gen/service/activity_user_procedure"
	activityUserPvLogGrpc "bgs/grpc/gen/service/activity_user_pv_log"
	activityService "bgs/service/activity"
	brandService "bgs/service/brand"
	productService "bgs/service/product"
	spokesmanService "bgs/service/spokesman"
	storeService "bgs/service/store"
	userService "bgs/service/user"
	"bgs/util"
	"context"

	"go.uber.org/zap"
)

// ActivityAPIService :grpc server proxy of product
type ActivityAPIService struct {
	dao  *db.PgDao
	slog *zap.SugaredLogger
	activityGrpc.ActivityOpServer
	activityStatGrpc.ActivityStatOpServer
	activityUserAwardGrpc.ActivityUserAwardOpServer
	activityUserProcedureGrpc.ActivityUserProcedureOpServer
	activityUserPvLogGrpc.ActivityUserPvLogOpServer
	cacher           *cache.Adapter
	activityService  *activityService.ActivityServiceImp
	brandService     *brandService.BrandServiceImp
	productService   *productService.ProductServiceImp
	spokesmanService *spokesmanService.SpokesmanServiceImp
	storeService     *storeService.StoreServiceImp
	userService      *userService.UserServiceImp
}

// NewActivityAPIService initialization
func NewActivityAPIService(
	pgdao *db.PgDao,
	slog *zap.SugaredLogger,
	vars *conf.VarsSection,
	proxy *client.GrpcClientProxy,
	adp *cache.Adapter,
	activityService *activityService.ActivityServiceImp,
	brandService *brandService.BrandServiceImp,
	productService *productService.ProductServiceImp,
	spokesmanService *spokesmanService.SpokesmanServiceImp,
	storeService *storeService.StoreServiceImp,
	userService *userService.UserServiceImp,
) *ActivityAPIService {
	return &ActivityAPIService{
		dao:              pgdao,
		slog:             slog.With("module", "ActivityAPIService"),
		cacher:           adp,
		activityService:  activityService,
		brandService:     brandService,
		productService:   productService,
		spokesmanService: spokesmanService,
		storeService:     storeService,
		userService:      userService,
	}
}

// NewContextLogger create a SugaredLogger with contextvalue
func (s *ActivityAPIService) NewContextLogger(ctx context.Context) *zap.SugaredLogger {
	return util.NewContextLogger(ctx, s.slog)
}
